**# Bookmark #1 Setting

*Windows
global root  = "G:/Dropbox/Environmental Injustice/Empirical"
global rawdata = "$root/rawdata"
global workdata = "$root/workdata"
global results = "$root/results"
global outfile = "$root/outfile"

cd "$workdata"

**# Bookmark #2 Panel A: Baseline City Demographic Characteristics in 2000
use "$outfile/City_regression.dta",clear

reghdfe codemission c.belowcl##i.post cityranking,absorb(i.province) cluster(i.province i.year)
keep if e(sample)==1

matrix T = J(4, 2, .)

sum belowhs

local mean = r(mean)
local sd = r(sd)

matrix T[1,1] = `mean'
matrix T[1,2] = `sd'

sum belowcl

local mean = r(mean)
local sd = r(sd)

matrix T[2,1] = `mean'
matrix T[2,2] = `sd'

sum rural

local mean = r(mean)
local sd = r(sd)

matrix T[3,1] = `mean'
matrix T[3,2] = `sd'

sum occupation

local mean = r(mean)
local sd = r(sd)

matrix T[4,1] = `mean'
matrix T[4,2] = `sd'

matrix list T
svmat T, names(col)
keep c1 c2
drop if c1==.
format c1 c2 %9.3f

**# Bookmark #3 Panel B: Firm- and City-level Pollution Measures
matrix T = J(4, 2, .)

use "$outfile/City_regression.dta",clear

reghdfe codemission c.belowcl##i.post,absorb(i.city i.province#i.year) cluster(i.province i.year)
keep if e(sample)==1

sum codemission

local mean = r(mean)
local sd = r(sd)

matrix T[1,1] = `mean'
matrix T[1,2] = `sd'


use "$outfile/Firm_regression.dta",clear

reghdfe codemission c.belowcl##i.post,absorb(i.id i.province#i.year) cluster(i.province i.year)

keep if e(sample)==1

sum codemission

local mean = r(mean)
local sd = r(sd)

matrix T[2,1] = `mean'
matrix T[2,2] = `sd'

use "$outfile/Firm_entry_regression.dta",clear

reghdfe entrynum c.belowcl##i.post,absorb(i.city i.province#i.year) cluster(i.province i.year)

keep if e(sample)==1

sum entrynum

local mean = r(mean)
local sd = r(sd)

matrix T[3,1] = `mean'
matrix T[3,2] = `sd'

use "$outfile/Firm_exit_regression.dta",clear

reghdfe exitnum c.belowcl##i.post,absorb(i.city i.province#i.year) cluster(i.province i.year)

keep if e(sample)==1

sum exitnum

local mean = r(mean)
local sd = r(sd)

matrix T[4,1] = `mean'
matrix T[4,2] = `sd'

matrix list T
svmat T, names(col)
keep c1 c2
drop if c1==.
format c1 c2 %9.3f


**# Bookmark #4 Panel C: Individual Health and Labor Outcomes
matrix T = J(5, 2, .)

use "$outfile/Individual_heartandday.dta",clear

reghdfe heart lowedu5_post_notapwater lowedu5_post lowedu5_notapwater notapwater_post lowedu5 notapwater post ,absorb(i.id i.province#i.year) cluster(i.province i.year)

keep if e(sample)==1

sum heart

local mean = r(mean)
local sd = r(sd)

matrix T[1,1] = `mean'
matrix T[1,2] = `sd'

use "$outfile/Individual_heartandday.dta",clear

reghdfe day lowedu5_post_notapwater lowedu5_post lowedu5_notapwater notapwater_post lowedu5 notapwater post ,absorb(i.id i.province#i.year) cluster(i.province i.year)

keep if e(sample)==1

sum day

local mean = r(mean)
local sd = r(sd)

matrix T[2,1] = `mean'
matrix T[2,2] = `sd'

use "$outfile/Individual_tumor.dta",clear

reghdfe tumor lowedu5_post_notapwater lowedu5_post lowedu5_notapwater notapwater_post lowedu5 notapwater post ,absorb(i.id i.province#i.year) cluster(i.province i.year)

keep if e(sample)==1

sum tumor

local mean = r(mean)
local sd = r(sd)

matrix T[3,1] = `mean'
matrix T[3,2] = `sd'

use "$outfile/Individual_hour.dta",clear

reghdfe hour lowedu5_post_notapwater lowedu5_post lowedu5_notapwater notapwater_post lowedu5 notapwater post ,absorb(i.id i.province#i.year) cluster(i.province i.year)

keep if e(sample)==1

sum hour

local mean = r(mean)
local sd = r(sd)

matrix T[4,1] = `mean'
matrix T[4,2] = `sd'

use "$outfile/Individual_wage.dta",clear

reghdfe wage_100 lowedu5_post_notapwater lowedu5_post lowedu5_notapwater notapwater_post lowedu5 notapwater post ,absorb(i.id i.province#i.year) cluster(i.province i.year)

keep if e(sample)==1

sum wage_100

local mean = r(mean)
local sd = r(sd)

matrix T[5,1] = `mean'
matrix T[5,2] = `sd'

matrix list T
svmat T, names(col)
keep c1 c2
drop if c1==.
format c1 c2 %9.3f
